package market

import (
	"context"

	"git.900sui.cn/kc/rpcinterface/interface/common"
)

/*
 * @Author: your name
 * @Date: 2021-06-01 11:18:33
 * @LastEditTime: 2021-06-18 10:18:22
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \rpcMarket\rpcinterface\interface\market\coupon.go
 */

const (
	REDIS_COUPON_KEY = "coupon-list-data-key"
	//时间类型：0-时间范围，1-领取当日有效，2-领取次日有效
	TIME_TYPE_0 = 0
	TIME_TYPE_1 = 1
	TIME_TYPE_2 = 2

	//领取类型：0-不限，1-每人限制次数
	LIMIT_TYPE_0 = 0
	LIMIT_TYPE_1 = 1

	//身份类型：0-不限，1-仅限制新会员
	IDENTITY_TYPE_0 = 0
	IDENTITY_TYPE_1 = 1
	//过期前提醒，0-代表不提醒，1以上为提醒的前天数
	NOTICE_EXPIRE_0  = 0
	NOTICE_EXPIRE_1  = 1
	NOTICE_EXPIRE_2  = 2
	NOTICE_EXPIRE_3  = 3
	NOTICE_EXPIRE_4  = 4
	NOTICE_EXPIRE_5  = 5
	NOTICE_EXPIRE_6  = 6
	NOTICE_EXPIRE_7  = 7
	NOTICE_EXPIRE_8  = 8
	NOTICE_EXPIRE_9  = 9
	NOTICE_EXPIRE_10 = 10

	//状态：1-进行中，2-未开始，3-已结束
	STATUS_CODE_0 = 1
	STATUS_CODE_1 = 2
	STATUS_CODE_2 = 3

	//优惠券类型：0-总部活动
	CONPON_TYPE_0 = 0

	//账户类型：1-总部，2-门店
	ACCOUNT_TYPE_1 = 1
	ACCOUNT_TYPE_2 = 2

	//适用范围：0-全部，1-指定门店
	SCOPE_TYPE_0 = 0
	SCOPE_TYPE_1 = 1

	//产品类型
	PRODUCT_TYPE_0 = 0
	PRODUCT_TYPE_1 = 1

	//日志类型字段,0-总店，1-用户
	LOG_ACCOUNT_TYPE_0 = 0
	LOG_ACCOUNT_TYPE_1 = 1

	//包含内容
	INCLUDE_SHOP    = "shop"
	INCLUDE_PRODUCT = "product"
)

//新增优惠券
type AddCouponArgs struct {
	common.BsToken
	Name              string  `length:"255" must:"Y"`
	Amount            float64 `length:"10" must:"Y"`
	Num               int     `length:"100" must:"Y"`
	UseType           int     `length:"2" must:"N"`
	FullAmount        float64 `length:"5" must:"N"`
	LimitType         int     `length:"2" must:"N"`
	LimitNum          int     `length:"10" must:"N"`
	ProductType       int     `length:"10" must:"N"`
	TimeType          int     `length:"2" must:"N"`
	StartTime         string     `length:"10" must:"N"`
	EndTime           string     `length:"10" must:"N"`
	Date              int     `length:"5" must:"N"`
	IdentityType      int     `length:"2" must:"N"`
	ScopeType         int     `length:"2" must:"N"`
	NoticeExpire      int     `length:"2" must:"N"`
	CouponShoptList   []CouponShopArgs
	CouponProductList []CouponProdArgs
	Desc              string `length:"1000" must:"N"`
}

//编辑优惠券
type EditCouponArgs struct {
	common.BsToken
	Id           int    `length:"11" must:"Y"`
	Name         string `length:"255" must:"N"`
	Num          int    `length:"100" must:"N"`
	LimitType    int    `length:"2" must:"N"`
	LimitNum     int    `length:"10" must:"N"`
	IdentityType int    `length:"2" must:"N"`
	NoticeExpire int    `length:"2" must:"N"`
	Desc         string `length:"1000" must:"N"`
}

//优惠券关联账户
type CouponShopArgs struct {
	ShopId int
}

//优惠券关联产品
type CouponProdArgs struct {
	ProdId   int
	ProdType int
}

//获取优惠券列表
type CouponListArgs struct {
	common.BsToken
	GetCouponArgs
}
type GetCouponArgs struct {
	Id      []int
	Name    string
	Status  int
	Include string
	common.Paging
}

type FindCouponsByUserArgs struct {
	common.Utoken
	Status int `length:"2" must:"Y"`
	common.Paging
}
type FindCouponsByUserIdArgs struct {
	Uid    int `length:"11" must:"Y"`
	Status int `length:"2" must:"Y"`
	common.Paging
}

type FindCouponByUserReplyList struct {
	TotalNum int
	Lists    []FindCouponByUserReply
}
type FindCouponByUserReply struct {
	Id             int
	CouponId       int
	CouponName     string
	Amount         float64
	TimeType       int
	StartTime      int
	EndTime        int
	UseType        int
	FullAmount     float64
	ProdId         int
	ProdType       int
	ShopId         int
	ShopName       string
	ShopImgUrl     string
	ShopBranchName string
	ShopAddress    string
	Status         int
	ReceiveType    int
	ReceivedTime   int
	ConsumedTime   int
}

type FindCouponByUserReplyListOfSaas struct {
	TotalNum int
	Lists    []FindCouponByUserReplyOfSaas
}
type FindCouponByUserReplyOfSaas struct {
	Id             int
	CouponId       int
	CouponName     string
	Amount         float64
	TimeType       int
	StartTime      string
	EndTime        string
	Date 		   int
	UseType        int
	FullAmount     float64
	ProdId         int
	ProdType       int
	ShopId         int
	ShopName       string
	ShopImgUrl     string
	ShopBranchName string
	ShopAddress    string
	Status         int
	ReceiveType    int
	ReceivedTime   int
	ConsumedTime   int
}


type CouponReplyList struct {
	TotalNum int
	Lists    []CouponReply
}
type CouponReply struct {
	Id                int
	Name              string
	Amount            float64
	UseType           int
	FullAmount        float64
	ProductType       int
	ScopeType         int
	Num               int
	ReceiveNum        int
	ReceivedNumOfUser int
	UsedNum           int
	TimeType          int
	StartTime         string
	EndTime           string
	Date 			  int
	LimitType         int
	LimitNum          int
	IdentityType      int
	NoticeExpire      int
	Status            int
	Type              int
	Desc              string
	CreateTime        int
	UpdateTime        int
	CouponShopList    []CouponShopReply `json:"CouponShopList,omitempty"`
	CouponProductList []CouponProdReply `json:"CouponProductList,omitempty"`
}


type UserCouponReplyList struct {
	TotalNum int
	Lists    []UserCouponReply
}
type UserCouponReply struct {
	Id                int
	Name              string
	Amount            float64
	UseType           int
	FullAmount        float64
	ProductType       int
	ScopeType         int
	Num               int
	ReceiveNum        int
	ReceivedNumOfUser int
	UsedNum           int
	TimeType          int
	StartTime         int
	EndTime           int
	LimitType         int
	LimitNum          int
	IdentityType      int
	NoticeExpire      int
	Status            int
	Type              int
	Desc              string
	CreateTime        int
	UpdateTime        int
	CouponShopList    []CouponShopReply `json:"CouponShopList,omitempty"`
	CouponProductList []CouponProdReply `json:"CouponProductList,omitempty"`
}

type CouponShopReply struct {
	ShopId   int
	ShopName string `json:"ShopName,omitempty"`
}
type CouponProdReply struct {
	ProdId    int
	ProdType  int
	ProdName  string  `json:"ProdName,omitempty"`
	ProdPrice float64 `json:"ProdPrice,omitempty"`
}

//停止优惠券
type StopCouponArgs struct {
	common.BsToken
	CouponId int
}

//消费优惠券
type ConsumeCouponArgs struct {
	Uid         int `length:"11" must:"Y"`
	CouponKeyId int `length:"11" must:"Y"`
}

//根据优惠券id获取详情
type GetCouponInfoArgs struct {
	common.BsToken
	BsId int `length:"11"`
	Id   int `length:"11" must:"Y"`
}

//根据优惠券id获取详情
type GetCouponInfoInternalArgs struct {
	BsId int `length:"11" must:"Y"`
	Id   int `length:"11" must:"Y"`
}
type GetCouponListByProdId struct {
	common.Utoken
	ShopId   int `length:"11" must:"Y"`
	ProdId   int `length:"11" must:"N"`
	ProdType int `length:"11" must:"N"`
	common.Paging
}

type ReceiveCouponArgs struct {
	common.Utoken
	CouponId    int `length:"11" must:"Y"`
	ShopId      int `length:"11" must:"Y"`
	ProdId      int `length:"11" must:"N"`
	ProdType    int `length:"11" must:"N"`
	ReceiveType int `length:"11" must:"Y"`
}

type FindCouponsByUserOfPcArgs struct {
	common.BsToken
	Uid         int `length:"2" must:"Y"`
	ProductId   int `length:"11" must:"Y"`
	ProductType int `length:"2" must:"Y"`
	common.Paging
}

type ReceiveCouponUserListByIdArgs struct {
	CouponId int `length:"11" must:"Y"`
}

type ReceiveCouponUserListByIdReply struct {
	Id          int
	Uid         int
	CouponId    int
	ShopId      int
	ProdId      int
	ProdType    int
	Num         int
	UsedNum     int
	ReceiveType int
	CreateTime  int
}

type GetCouponListByShopIdOfAppArgs struct {
	ShopId []int
}

type GetCouponListByShopIdOfAppReply struct {
	ShopId       int
	CouponId     int
	CouponName   string
	CouponAmount float64
	Num          int
	ReceiveNum   int
	LimitType    int
	LimitNum     int
	UseType      int
	FullAmount   float64
	EndTime      int
}

type GetReceivedCouponListOfOrderArgs struct {
	common.Utoken
	ShopId      int `length:"11" must:"Y"`
	ProductId   int `length:"11" must:"Y"`
	ProductType int `length:"11" must:"Y"`
	common.Paging
}

type GetReceivedCouponListOfOrderReplies struct {
	TotalNum int
	Lists    []GetReceivedCouponListOfOrderReply
}

type GetReceivedCouponListOfOrderReply struct {
	Id           int
	CouponId     int
	CouponName   string
	Amount       float64
	ReceiveType  int
	ShopId       int
	ProductId    int
	ProductType  int
	Num          int
	UsedNum      int
	Status       int
	UseType      int
	FullAmount   float64
	IdentityType int
	StartTime    int
	EndTime      int
	ReceivedTime int
}

type Coupons interface {

	//商户-增加优惠券
	AddCoupon(ctx context.Context, args *AddCouponArgs, reply *bool) error
	//商户-编辑优惠券
	EditCoupon(ctx context.Context, args *EditCouponArgs, reply *bool) error
	//商户-获取优惠券列表
	CouponList(ctx context.Context, args *CouponListArgs, reply *CouponReplyList) error
	//商户-停止优惠券
	StopCoupons(ctx context.Context, args *StopCouponArgs, reply *bool) error
	//SAAS-按照id获取优惠券详情
	FindCouponById(ctx context.Context, args *GetCouponInfoArgs, reply *CouponReply) error
	//SAAS-消费优惠券
	ConsumeCouponsByUser(ctx context.Context, args *ConsumeCouponArgs, reply *bool) error
	//SAAS-查找已领取过的优惠券
	FindCouponsByUserOfPc(ctx context.Context, args *FindCouponsByUserOfPcArgs, reply *FindCouponByUserReplyListOfSaas) error
	//用户-获取用户数量
	GetCouponNumByUser(ctx context.Context,uid *int, num *int)error
	//用户-查找已领取过的优惠券列表
	FindCouponsByUser(ctx context.Context, args *FindCouponsByUserArgs, reply *FindCouponByUserReplyList) error
	//用户-根据产品获取优惠券信息及列表
	CouponListByConds(ctx context.Context, args *GetCouponListByProdId, reply *UserCouponReplyList) error
	//用户-领取优惠券
	ReceiveCouponByUser(ctx context.Context, args *ReceiveCouponArgs, reply *bool) error

	//通用-按照couponid获取用户优惠券数据
	GetReceivedCouponUserListById(ctx context.Context, args *ReceiveCouponUserListByIdArgs, reply *[]ReceiveCouponUserListByIdReply) error

	//用户-根据shopid获取相应的优惠卡券
	GetCouponListByShopIdOfApp(ctx context.Context, args *GetCouponListByShopIdOfAppArgs, reply *map[int][]GetCouponListByShopIdOfAppReply) error
	//internal-按照id获取优惠券详情
	FindCouponByIdOfInternal(ctx context.Context, args *GetCouponInfoArgs, reply *CouponReply) error
	//订单部分-已领取优惠券
	GetReceivedCouponListOfOrder(ctx context.Context, args *GetReceivedCouponListOfOrderArgs, replies *GetReceivedCouponListOfOrderReplies) error
	//根据用户领取的主键id，获取优惠券信息
	GetUserCouponInfoById(ctx context.Context, kId *int, reply *int) error
	//取消消费券使用
	CancelCoupon(ctx context.Context, kId *int) error
}
